import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_learn_vi/src/bean/bean_user.dart';
import 'package:flutter_learn_vi/src/common/user_helper.dart';
import 'package:flutter_learn_vi/src/utils/navigator_utils.dart';
import 'package:flutter_learn_vi/src/utils/string_utils.dart';

import 'mine_person_resum_add_page.dart';

/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 2021/2/15.
///
/// 可关注公众号：我的大前端生涯   获取最新技术分享
/// 可关注网易云课堂：https://study.163.com/instructor/1021406098.htm
/// 可关注博客：https://blog.csdn.net/zl18603543572
///

///工作简历
class MinePersonResumPage extends StatefulWidget {
  final UserBean userBean;

  const MinePersonResumPage({Key key, this.userBean}) : super(key: key);

  @override
  _MinePersonResumPageState createState() => _MinePersonResumPageState();
}

class _MinePersonResumPageState extends State<MinePersonResumPage> {
  String _userResume;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _userResume = widget.userBean.userResume;
  }

  @override
  Widget build(BuildContext context) {
    if (StringUtils.isEmpty(_userResume)) {
      _userResume = "暂无";
    }
    return Scaffold(
      appBar: AppBar(
        title: Text("工作简历"),
        actions: [
          buildRightButton(),
        ],
      ),
      backgroundColor: Colors.white,

      ///填充布局
      body: Container(
          width: double.infinity,
          height: double.infinity,
          padding: EdgeInsets.all(12),
          child: SingleChildScrollView(
            child: Container(
              child: Text(
                "$_userResume",
                style: TextStyle(fontSize: 16),
              ),
            ),
          )),
    );
  }

  buildRightButton() {
    int userId = widget.userBean.userId;
    int selefUserId = UserHelper.getInstance.userBean.userId;
    if (userId == selefUserId) {
      return TextButton(
        onPressed: () {
          NavigatorUtils.pushPage(context, MinePersonResumAddPage(),
              callback: (value) {
            if (value != null) {
              _userResume = value;
              setState(() {});
            }
          });
        },
        child: Text("编辑"),
      );
    }
    return Container();
  }
}
